package model;

import java.awt.Color;
import java.awt.Graphics;

/**
 * <p>
 * Title: DrawableVertex</p>
 * <p>
 * Description: CS 343 Project. Allows vertices to be drawn on the graph.</p>
 *
 * @date 11/18/2013
 *
 * @author Dylan Ahmann
 * @author Gregg Roemhildt - Class Programming and Javadocs
 * @author Sam Brockmann - Javadocs
 * @author Emily Hancock
 * @author Shirin Asadi
 *
 */
public class DrawableVertex extends Vertex<double[]> implements Drawable {

    private final int DIAMETER = 10;
    private final int OFFSET = -5;

    /**
     * default constructor
     *
     * @param d pointData
     * @param n name
     *
     * Initializes pointData and name.
     */
    public DrawableVertex(double[] d, String n) {
        super(d, n);
    }

    /**
     * alternate constructor
     *
     * @param v Vertex
     *
     * Initializes vertex.
     */
    public DrawableVertex(Vertex<double[]> v) {
        super(v);
    }

    /**
     * paint
     *
     * @param g defines color pattern
     *
     * Paints a vertex on a map.
     */
    @Override
    public void paint(Graphics g) {
        Color c = g.getColor();
        g.fillOval((int) pointData[0] + OFFSET, (int) pointData[1]
                + OFFSET, DIAMETER, DIAMETER);
        g.setColor(Color.BLACK);
        g.drawString(this.toString(), (int) pointData[0], (int) pointData[1]);
        g.setColor(c);
    }

    /**
     *
     *
     * @param g defines color pattern
     * @param x x-offset
     * @param y y-offset
     * @param z zoom level
     */
    public void paint(Graphics g, double x, double y, double z) {
        Color c = g.getColor();
        int x1 = (int) ((pointData[0] + x) * z);
        int y1 = (int) ((pointData[1] + y) * z);

        g.fillOval(x1 + OFFSET, y1 + OFFSET, DIAMETER, DIAMETER);
        g.setColor(Color.BLACK);
        g.drawString(this.toString(), x1, y1);
        g.setColor(c);
    }
}
